﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Sparkle.UI;
using Sparkle.Demo.Model;
using System.Windows.Controls;
using Sparkle.Hosting;

namespace Sparkle.Wpf.Demo.UI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            UIDefaults.RegisterdControls.Add(typeof(Address),
                new RegisterdControl() 
                {
                    ControlType = typeof(GenericObjectSelector),
                    DefaultWidth = 200,
                    BindingProperty = UserControl.DataContextProperty,
                    OnDataBinding= delegate(Control control, object value)
                    {
                        if (control is GenericObjectSelector)
                        {
                            AddressController addrContVM = new AddressController();
                            addrContVM.Model = value as IModel;

                            (control as GenericObjectSelector).DataContext = addrContVM;
                        }
                    }
                });
        }
    }
}
